# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Dan McGee <dan@archlinux.org>

pkgbase=doxygen
pkgname=('doxygen' 'doxygen-docs')
pkgver=1.8.14
pkgrel=1
pkgdesc='Documentation system for C++, C, Java, IDL and PHP'
url='http://www.doxygen.org/'
arch=('x86_64')
license=('GPL')
makedepends=('cmake' 'gcc-libs' 'flex' 'qt5-base' 'texlive-core' 'ghostscript'
             'texlive-latexextra' 'graphviz' 'python2')
source=(${pkgbase}-${pkgver}.tar.gz::https://github.com/doxygen/doxygen/archive/Release_${pkgver//./_}.tar.gz)
sha256sums=('18bc3790b4d5f4d57cb8ee0a77dd63a52518f3f70d7fdff868a7ce7961a6edc3')
sha512sums=('e19d706be64f8c1d35d3cd12b8c35f09503213bb3f5a4aa311ef0a6a953843ebed5ac4eca52ca908222543fb9794d545bb6d88c9fc8f39e66ef22c1919c120b0')

prepare() {
  cd ${pkgbase}-Release_${pkgver//./_}

  mkdir build

  # Install the man pages in the right place
  sed -i 's:DESTINATION man/man1:DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1":g' \
    doc/CMakeLists.txt
}

build() {
  cd ${pkgbase}-Release_${pkgver//./_}/build

  cmake .. \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DDOC_INSTALL_DIR:PATH=share/doc/doxygen \
    -DPYTHON_EXECUTABLE:FILE=/usr/bin/python2 \
    -Dbuild_doc:BOOL=ON \
    -Dbuild_wizard:BOOL=ON

  make
  make docs
}

check(){
  cd ${pkgbase}-Release_${pkgver//./_}/build
  make tests
}

package_doxygen() {
  pkgdesc='Documentation system for C++, C, Java, IDL and PHP'
  depends=('gcc-libs')
  optdepends=('graphviz: for caller/callee graph generation'
              'qt5-base: for doxywizard')

  cd ${pkgbase}-Release_${pkgver//./_}/build
  make DESTDIR="${pkgdir}" install

  # Docs are in 'doxygen-docs'
  rm -rf "${pkgdir}/usr/share/doc"
}

package_doxygen-docs() {
  pkgdesc='Developer documentation for doxygen'

  cd ${pkgbase}-Release_${pkgver//./_}/build
  make DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}/usr/bin"
  rm -rf "${pkgdir}/usr/share/man"
}

# vim: ts=2 sw=2 et:
